﻿@model BBICMS.Model.ViewModel.Identity.LoginVM
@{
    ViewBag.Title = Title.MemberLogin;
}


@section header{   
    <link href="~/Content/iconfont/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="~/plugins/toastr/toastr.min.css" rel="stylesheet" />
}


@section featured{
    <div class="sitepath">
        <div class="container">
            <div class="row">
              
                <div class="col-xs-8">
                    <ol class="breadcrumb">
                        <li><a href="/">@Menu.Home</a></li>
                        <li class="active">@ViewBag.Title</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
}


<div class="container page-login">
    <h3 class="sectiontitle">
        @ViewBag.Title
    </h3>

    <div class="panel panel-default">  
        <div class="panel-body">
            <div class="loginform">

                @using (Ajax.BeginForm("login", "account",
                                                      new AjaxOptions()
                                                      {
                                                          HttpMethod = "POST",
                                                   
                                                          OnBegin = "onBegin",
                                                          OnComplete = "onComplete",
                                                          OnSuccess = "onSuccess"

                                                      }, new { role = "form", Area = "" }))
                {
                    @Html.AntiForgeryToken()
                    @Html.ValidationSummary(true)
                    @Html.HiddenFor(m => m.ReturnUrl)

                    <div class="form-group">
                        @Html.LabelFor(u=>u.UserName)                   
                        @Html.TextBoxFor(m => m.UserName, new { @class = "form-control", placeholder = Placeholder.UserName })
                        @Html.ValidationMessageFor(m => m.UserName)
                    </div>

                        <div class="form-group">
                            @Html.LabelFor(u => u.Password) 
                            @Html.PasswordFor(m => m.Password, new { @class = "form-control", placeholder = Placeholder.YourPassword })
                            @Html.ValidationMessageFor(m => m.Password)
                        </div>

                        <div class="checkbox">
                            <label>
                                @Html.CheckBoxFor(m => m.RememberMe) @Labels.RememberMe
                            </label>
                        </div>
                        <div class="form-group">
                            <button type="submit" id="btnLogin" class="btn btn-primary btn-block"><i class="fa fa-sign-in fa-fw"></i> @Buttons.Login</button>
                            </div>
                            <p>
                                <a href="@Url.Action("Register")">@Labels.HaveNoAccountRegistNow</a>
                            </p>

                }


            </div>



        </div>

    </div>

</div>


    @section scripts {
        @Scripts.Render("~/bundles/jqueryvalWithBootstrap")
<script src="~/plugins/toastr/toastr.min.js"></script>
        <!-- pre load bg imgs -->
        <script type="text/javascript">
            function onBegin() {
                $("#btnLogin i").removeClass("fa-sign-in").addClass("fa-spinner fa-spin")
            }
            function onComplete() {
                $("#btnLogin i").removeClass("fa-spinner fa-spin").addClass("fa-sign-in")
            }
            function onSuccess(data) {

                if (data.Status == 1) {
                    toastr.success(data.Message, "@ViewBag.Title");
                    if (data.Data == null) {
                       // debugger;
                        location.href = "/";
                    } else {
                       // debugger;
                        location.href = data.Data;
                    }


                }

                if (data.Status == 2) {
                    toastr.error(data.Message, "@ViewBag.Title");
                }

            }
        </script>
    }
